package org.newlucene.core.document;

import java.util.HashMap;
import java.util.Map;

/** Documents are the unit of indexing and search.
 *
 * A Document is a set of fields.  Each field has a name and a textual value.
 * A field may be stored with the document, in which case it is returned with
 * search hits on the document.  Thus each document should typically contain
 * stored fields which uniquely identify it.
 * */

public final class Document 
{
	Map<String, String> nameValueHash = new HashMap<String, String>(10);
  
	/** Constructs a new document with no fields. */
	public Document() {}

	/** Adds a field to a document.  Several fields may be added with
	 * the same name.  In this case, if the fields are indexed, their text is
	 * treated as though appended for the purposes of search. */
	public final void add(String fieldName, String fieldValue)
	{
		nameValueHash.put(fieldName, fieldValue);
	}

	public final String get(String fieldName)
	{
		return nameValueHash.get(fieldName);
	}	
	
	public final boolean containsField(String fieldName)
	{
		return nameValueHash.containsKey(fieldName);
	}
}
